package com.liuxin.zhiyuan.shujuzhongxin.service.impl;

import com.liuxin.zhiyuan.shujuzhongxin.mapper.HistoricalAdmissionScoreMapper;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuxin.common.utils.PageUtils;
import com.liuxin.common.utils.Query;

import com.liuxin.zhiyuan.shujuzhongxin.domain.po.HistoricalAdmissionScoreEntity;
import com.liuxin.zhiyuan.shujuzhongxin.service.HistoricalAdmissionScoreService;


@Service
public class HistoricalAdmissionScoreServiceImpl extends ServiceImpl<HistoricalAdmissionScoreMapper, HistoricalAdmissionScoreEntity> implements HistoricalAdmissionScoreService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<HistoricalAdmissionScoreEntity> page = this.page(
                new Query<HistoricalAdmissionScoreEntity>().getPage(params),
                new QueryWrapper<HistoricalAdmissionScoreEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<HistoricalAdmissionScoreEntity> findBySchoolIdAndPro(Integer schoolId, String pro,String nature) {
        QueryWrapper<HistoricalAdmissionScoreEntity> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("school_id", schoolId)
                .eq("pro", pro)
                .in("year", "2023", "2024")
                .eq("nature", nature)
                .ne("low_score", 0)
                .ne("low_rank", 0)
                .orderByDesc("year");
        return this.list(queryWrapper);
    }

     @Override
    public Integer findSchoolCodeAverageRank(Integer schoolId, String schoolCode,String nature) {
        return baseMapper.findSchoolCodeAverageRank(schoolId, schoolCode,nature);
    }

}